<template>
    <div>
        <el-table :data="getlist" row-key="id" :tree-props="{ children: 'children' }" default-expand-all border
            style="width: 100%">
            <el-table-column prop="id" label="分类编号">
            </el-table-column>
            <el-table-column prop="catename" label="分类名称" align="center">
            </el-table-column>
            <el-table-column prop="img" label="图片" align="center">
                <template v-if="item.row.img" slot-scope="item">
                    <div class="img">
                        <img :src="'http://localhost:3070' + item.row.img" alt="">
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="status" label="状态" align="center">
                <template slot-scope="item">
                    <!-- item.row 代表的是table中的每一行数据 -->
                    <div>
                        <!-- {{item.row}} -->
                        <!-- {{ item.row.status == 1 ? "启用" : "禁用" }} -->
                        <el-tag v-if="item.row.status == 1" type="success">启用 </el-tag>
                        <el-tag type="danger" v-else> 禁用</el-tag>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="item">
                    <el-button type="primary" icon="el-icon-edit" @click="edit(item.row.id)" circle></el-button>
                    <el-button type="danger" icon="el-icon-delete" @click="del(item.row.id)" circle></el-button>
                </template>
            </el-table-column>
        </el-table>

    </div>
</template>

<script>
import { catelist, catedelete, cateedit, cateinfo } from '../../request/app'
import { mapGetters, mapActions } from 'vuex'
export default {
    data() {
        return {
        };
    },
    methods: {
        ...mapActions({
            // ACsetlist: 'setmange/ACsetlist',
            // ACgetlistpeo:'setpeople/ACgetlistpeo'
            ACsetlist: 'toshop/ACsetlist'
        }),
        // 改变下标传递页数

        // 修改
        edit(uid) {
            this.$emit('manedit', uid)

        },
        // 删除
        del(id) {
            // console.log(uid);
            catedelete({
                id
            })
                .then(res => {
                    console.log(res);
                    this.ACsetlist()
                })

        }
    },
    // 计算属性
    computed: {
        // 映射vuex
        ...mapGetters({
            getlist: 'toshop/getlist',
            // getpages: 'setmange/getpages',
            // peogetlist : 'setpeople/getlist'
        })
    },
    // 页面一加载
    mounted() {
        // console.log(this.getlist);
        this.ACsetlist()
    },
    components: {
    },
}
</script>

<style scoped>
.img img {
    width: 100%;
}
</style>
